package com.ruoyi.hospital.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hospital.domain.Synopsis;
import com.ruoyi.hospital.service.ISynopsisService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 医院简介Controller
 * 
 * @author ruoyi
 * @date 2022-09-08
 */
@RestController
@RequestMapping("/hospital/synopsis")
public class SynopsisController extends BaseController
{
    @Autowired
    private ISynopsisService synopsisService;

    /**
     * 查询医院简介列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:synopsis:list')")
    @GetMapping("/list")
    public TableDataInfo list(Synopsis synopsis)
    {
        startPage();
        List<Synopsis> list = synopsisService.selectSynopsisList(synopsis);
        return getDataTable(list);
    }

    /**
     * 导出医院简介列表
     */
    @PreAuthorize("@ss.hasPermi('hospital:synopsis:export')")
    @Log(title = "医院简介", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Synopsis synopsis)
    {
        List<Synopsis> list = synopsisService.selectSynopsisList(synopsis);
        ExcelUtil<Synopsis> util = new ExcelUtil<Synopsis>(Synopsis.class);
        util.exportExcel(response, list, "医院简介数据");
    }

    /**
     * 获取医院简介详细信息
     */
    @PreAuthorize("@ss.hasPermi('hospital:synopsis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(synopsisService.selectSynopsisById(id));
    }

    /**
     * 新增医院简介
     */
    @PreAuthorize("@ss.hasPermi('hospital:synopsis:add')")
    @Log(title = "医院简介", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Synopsis synopsis)
    {
        return toAjax(synopsisService.insertSynopsis(synopsis));
    }

    /**
     * 修改医院简介
     */
    @PreAuthorize("@ss.hasPermi('hospital:synopsis:edit')")
    @Log(title = "医院简介", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Synopsis synopsis)
    {
        return toAjax(synopsisService.updateSynopsis(synopsis));
    }

    /**
     * 删除医院简介
     */
    @PreAuthorize("@ss.hasPermi('hospital:synopsis:remove')")
    @Log(title = "医院简介", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(synopsisService.deleteSynopsisByIds(ids));
    }
}
